﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NaiveBayesClassifier
{
    public class CStringAttribute : IAttribute
    {
        public const string DEFAULT_VALUE = "*";

        private string name;
        private string value;

        #region Getter & Setter
        public string GetName()
        {
            return this.name;
        }

        public object GetValue()
        {
            return this.value;
        }

        public void SetValue(string value)
        {
            this.value = value;
        }
        #endregion

        public CStringAttribute(string name, string value)
        {
            this.name = name;
            this.value = value;
        }

        public override bool Equals(object obj)
        {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (!(obj is CStringAttribute))
                return false;

            CStringAttribute other = (CStringAttribute)obj;
            if (name == null)
            {
                if (other.name != null)
                    return false;
            }
            else if (!name.Equals(other.name))
                return false;
            if (value == null)
            {
                if (other.value != null)
                    return false;
            }
            else if (!value.Equals(other.value))
                return false;
            return true;
        }

        public override int GetHashCode()
        {
            return name.GetHashCode() + value.GetHashCode();
        }
    }
}
